package com.tedu.micro.service.service.impl;

import com.tedu.micro.service.mapper.StockMapper;
import com.tedu.micro.service.service.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class StockServiceImpl implements StockService {
    @Autowired
    private StockMapper stockMapper;
    @Override
    public Boolean reduceStock(String productCode, Integer count) {
        //update stock_tbl set stock=stock-#{count} where product_code=#{productCode}
        //这样减库存永远能减成功 添加约束 stock>#{count}
        //mybatis-plus不好直接调用 自己写
        Integer result = stockMapper.reduceStock(productCode, count);
        return result>=1;
    }
}
